package com.example.gsq.news.base;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.example.gsq.news.util.C;

public class BaseFragment extends Fragment {

    protected BaseTaskPool mTaskPool;
    protected BaseActivity mActivity;
    protected BaseHandler mHandler;

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mActivity = (BaseActivity) this.getActivity();
        mHandler = new BaseHandler(this);
        mTaskPool = new BaseTaskPool(mHandler);
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if(getUserVisibleHint()) {
        } else {
        }
    }




    public void doAsyncTask(int taskId, String urlString){
        mTaskPool.addTask(taskId, C.TaskType.TASK_PULL_REFRESH, urlString);
    }

    public void doAsyncTask(int taskId, int taskType, String urlString){
        mTaskPool.addTask(taskId, taskType, urlString);
    }

    public void onTaskComplete(int taskId, int taskType, String responseString){
    }

    public void onTaskComplete(int taskId, int taskType, Bitmap bitmap, String imageUrl){
    }

//    private boolean isCanceld = false;
//    public void cancelAllTasks(){
//        isCanceld = true;
//    }

}
